import request from '@/utils/request'

// 查询商家品项列表
// export function listItem(query) {
//   return request({
//     url: '/product/item/list',
//     method: 'get',
//     params: query
//   })
// }


export function getDic(shopId) {
  return request({
    url: '/work/shop/getGoodsDic',
    method: 'get',
    params: { "shopId": shopId }
  })
}

//获取当前登录人店铺
export function getShop() {
  return request({
    url: '/work/shop/getShopByLoginUser',
    method: 'get',
  })
}
//当前登录人所有品相
export function listItem(query) {
  return request({
    url: '/work/shop/getProjects',
    method: 'get',
    params: query
  })
}

// 查询商家品项详细
export function getItem(id) {
  return request({
    url: '/product/item/' + id,
    method: 'get'
  })
}

// 新增商家品项
export function addItem(data) {
  return request({
    url: '/work/shop/project/saveOrUpdate',
    method: 'post',
    data: data
  })
}

// 修改商家品项
export function updateItem(data) {
  return request({
    url: '/work/shop/project/saveOrUpdate',
    method: 'post',
    data: data
  })
}

// 删除商家品项
export function delItem(id) {
  return request({
    url: '/work/shop/project/delete-by-id',
    method: 'get',
    params: { "id": id }
  })
}

//修改或者删除商铺
export function updateShop(data) {
  return request({
    url: '/work/shop/saveOrUpdate',
    method: 'post',
    data: data
  })
}

export function getItemById(id) {
  return request({
    url: '/work/shop/getProject/' + id,
    method: 'get',
  })
}

// 删除品相和产品关联
export function delItemAndgood(id) {
  return request({
    url: '/work/shop/projectAndGood/delete-by-id',
    method: 'get',
    params: { "id": id }
  })
}

// 保存或者修改商品关联
export function updateOrAdd(data) {
  return request({
    url: '/work/shop/projectAndGood/save',
    method: 'post',
    data: data
  })
}

// 生成店铺码
export function createCode() {
  return request({
    url: '/work/shop/createQrCode',
    method: 'get',
  })
}

export function getFileById(fileId) {
  return request({
    url: '/files/getFileById',
    method: 'get',
    params: { "id": fileId }
  })
}

